import { defineStore } from "pinia"
import { ref } from "vue"
import { getCommentListApi } from "@/api/comments"
let useComments = defineStore('comments', () => {
    //评论的列表数据
    let commentsList = ref([])
    //声明一个方法专门获取评论数据 重点,因为需要通过这个方法来更新列表
    let getComments = async () => {
        try {
            let data = await getCommentListApi();
            // console.log(data)
            commentsList.value = data
        } catch (e) {
            //捕获异常
            console.log(e.toString())
        }
    };
    return {
        commentsList,
        getComments
    }
})

export default useComments